#include <bits/stdc++.h>

using std::swap;
using std::min;

const int maxn=105;
const int maxm=30005;
const int inf=0x3f3f3f3f;

int g[maxn],v[maxm],c[maxm],nxt[maxm];
int dis[maxn],cur[maxn];
int S,T;

inline void addEdge(const int &x,const int &y,const int &z){
	static int en=0;
	v[en]=y;nxt[en]=g[x];c[en]=z;g[x]=en++;
	v[en]=x;nxt[en]=g[y];c[en]=0;g[y]=en++;
}
bool bfs(){
	static int q[maxn];
	memset(dis,-1,sizeof dis);
	int f,r;
	f=r=0;dis[S]=0;cur[S]=g[S];
	for(q[r++]=S;f<r;f++){
		const int &now=q[f];
		for(int j=g[now];~j;j=nxt[j]){
			const int &tar=v[j];
			if(~dis[tar]) continue;
			if(!c[j]) continue;
			dis[tar]=dis[now]+1;
			cur[tar]=g[tar];
			q[r++]=tar;
		}
	}
	return ~dis[T];
}
int dfs(int p,int flow){
	if(p==T) return flow;
	int alpha=flow,fl;
	for(int &j=cur[p];~j;j=nxt[j]){
		const int &tar=v[j];
		if(c[j]&&dis[tar]==dis[p]+1&&(fl=dfs(tar,min(c[j],alpha)))){
			c[j]-=fl;c[j^1]+=fl;alpha-=fl;
			if(!alpha) break;
		}
	}
	return flow-alpha;
}

int main(){
	int n,n1,ans;
	int x,y;

	freopen("flyer.in","r",stdin);
	freopen("flyer.out","w",stdout);

	scanf("%d%d",&n,&n1);
	memset(g,-1,sizeof g);
	while(~scanf("%d%d",&x,&y)) addEdge(x,y,1);
	S=0;T=n+1;
	for(int i=1;i<=n1;i++) addEdge(S,i,1);
	for(int i=n1+1;i<=n;i++) addEdge(i,T,1);

	ans=0;
	while(bfs()) ans+=dfs(S,inf);
	printf("%d\n",ans);

	return 0;
}